﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Supervise_GMPList : System.Web.UI.Page
{
    public string strConditions, AccountId;

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupervise);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
        AccountId = SysFun.IsSQL(Request.QueryString["AccountId"]);

        //string delGMPId = Request.Form["chk"].ToString();
        //string strSql = "delete from companygmp where [id] in (" + delGMPId + ") and accountid=" + AccountId;
        //Db db = new Db();
        //db.Command(strSql);
        //db.Close();
     

            showGridView();
       }

    }
    protected void Button5_Click(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 数据绑定
    /// </summary>
    public void showGridView()
    {
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "COMPANY INNER JOIN COMPANYGMP ON COMPANY.ACCOUNTID=COMPANYGMP.ACCOUNTID";                                               //要查询的表明
        dbPage.Key = " COMPANYGMP.[ID]";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = " COMPANYGMP.[ID],COMPANY.ACCOUNTID,COMPANY.COMPANYNAME,COMPANY.USERCODE,COMPANYGMP.GMPCODE,COMPANYGMP.GMPSTARDATE,COMPANYGMP.GMPENDDATE,COMPANYGMP.GMPRANGE";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 10;                                                    //没有显示记录条数   
        dbPage.OrderBy = "COMPANYGMP.GMPCODE";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlAttorney.DataSource = dr;
        DlAttorney.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        string strtemp = "", GMPCODE = "", GMPRANGE;

        strtemp = " COMPANYGMP.AccountId=" + SysFun.IsSQL(Request.QueryString["AccountId"]) + " and";
        GMPCODE = txtGMPCODE.Text.ToString();
        GMPRANGE = txtGMPRANGE.Text.ToString();
        if (GMPRANGE != "")
        {
            strtemp = strtemp + " COMPANYGMP.GMPRANGE like '%" + GMPRANGE + "%' and";
        }
        if (GMPCODE != "")
        {
            strtemp = strtemp + " COMPANYGMP.GMPCODE like '%" + GMPCODE + "%' and";
        }
        if (strtemp != "")
        {
            strtemp = "  " + strtemp.Substring(0, strtemp.Length - 3);
        }
        return strtemp;
    }

}
